namespace ScrumSprintMonitor.Wpf.Application
{
	#region #using Directives

	using System.Windows;
	using System.Windows.Input;

	using Infrastructure.Configuration;

	#endregion

	/// <summary>
	/// Interaction logic for SecondaryMonitorShell.xaml
	/// </summary>
	public partial class SecondaryMonitorShell : Window
	{
		private readonly IShellLayoutConfiguration shellLayoutConfiguration;

		public SecondaryMonitorShell(IShellLayoutConfiguration shellLayoutConfiguration)
		{
			this.shellLayoutConfiguration = shellLayoutConfiguration;

			InitializeComponent();
		}

		private void OnShellLoaded(object sender, RoutedEventArgs e)
		{
			WindowState = WindowState.Maximized;

			if (this.shellLayoutConfiguration.RunningAsScreensaver)
			{
				Topmost = true;
			}
		}

		private void OnShellMouseDown(object sender, MouseButtonEventArgs e)
		{
			if (this.shellLayoutConfiguration.RunningAsScreensaver)
			{
				Close();
				Application.Current.Shutdown();
			}
		}

		private void OnShellKeyDown(object sender, KeyEventArgs e)
		{
			if (this.shellLayoutConfiguration.RunningAsScreensaver)
			{
				Close();
				Application.Current.Shutdown();
			}
		}
	}
}